package com.dao;

import java.util.List;

import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.po.TrainPO;

@Repository
public class TrainDao {
	@Autowired
	private SqlSessionTemplate sqlTemplate;

	/**
	 * 查找项目列表
	 * @return
	 */
	public List<TrainPO> findTrainInfo() {
		
		return sqlTemplate.selectList("train.findTrainInfo");
	}
	/**
	 * 查找项目的详细信息
	 * @param id
	 * @return
	 */
	public TrainPO findTrainDetailInfo(int id) {
		
		return sqlTemplate.selectOne("train.findTrainDetailInfo",id);
	}
	/**
	 * 修改项目信息
	 * @param trainPO
	 */
	public void update(TrainPO trainPO) {
		sqlTemplate.update("train.update_train", trainPO);
		
	}
	/**
	 * 删除项目
	 * @param id
	 */
	public void delete(int id) {
		sqlTemplate.update("train.delete", id);
		
	}
	/**
	 * 添加项目
	 * @param trainPO
	 */
	public void addTrainInfo(TrainPO trainPO) {
		sqlTemplate.insert("train.addTrainInfo",trainPO);
	}
}
